const debounce = function (func, wait = 3000) {
    let timeout
    return function () {
        if (timeout) { clearTimeout(timeout) }
        let callNow = !timeout
        timeout = setTimeout(() => {
            timeout = null
        }, wait)
        if (callNow) {
            func.apply(this)
        }
    }
}

export default debounce;